package com.example.fbzdemooracke.controller;

import com.example.fbzdemooracke.PO.FbzDemoPO1;
import com.example.fbzdemooracke.PO.FbzDemoPO2;
import com.example.fbzdemooracke.annotiation.TestAnnotiation;
import com.example.fbzdemooracke.dao.FbzDemoMapper;
import com.example.fbzdemooracke.domain.FbzDemo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;

@RestController
@RequestMapping("/user")
public class FbzDemoController {
    @Autowired
    FbzDemoMapper fbzDemoMapper;

    @PostMapping("getById")
    @TestAnnotiation
    public HashMap<String ,Object> getById(@RequestBody @Validated FbzDemoPO1 fbzDemoPO1){
        HashMap<String ,Object> map=new HashMap<>();
        map.put("result",fbzDemoMapper.selectByPrimaryKey(fbzDemoPO1.getId()));
        return map;
    }

    @Autowired
    HttpServletRequest request;

    @PostMapping("add")
    public void add(@RequestBody @Validated FbzDemoPO2 fbzDemoPO2){
        FbzDemo fbzDemo=new FbzDemo();
        BeanUtils.copyProperties(fbzDemoPO2,fbzDemo);
        fbzDemoMapper.insertSelective(fbzDemo);

    }


}
